package com.lg.cms.controller.admin.article;

import com.lg.cms.service.ArticleService;
import com.lg.cms.service.ArticleTypeService;
import com.lg.cms.service.CategoryService;
import com.lg.cms.service.TagsService;
import com.lg.cms.utils.UploadFileUtil;
import com.lg.cms.vo.LayerTableVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author:MaShucahng
 * @date: 2020/11/22 17:32
 */
@Controller
@RequestMapping("/admin/wlt/type")
@Api(tags = "类型管理")
public class TypeController {
    @Autowired
    CategoryService categoryService;
    @Resource
    UploadFileUtil uploadFileUtil;
    @Autowired
    ArticleService articleService;
    @Autowired
    ArticleTypeService articleTypeService;
    @Autowired
    TagsService tagsService;


    /**
     * 访问类型管理
     * @param model
     * @param request
     * @return
     */
    @GetMapping("/lists")
    public String address(Model model, HttpServletRequest request) {
        model.addAttribute("request", request);
//        model.addAttribute("articleTypeList", articleTypeService.list());
//        model.addAttribute("articleService", articleService.Binding_typeArticle());


        return "/admin/wlt-test/classification";
    }




    /***
     *
     * 显示类型列表
     *
     */

    @GetMapping("/list")
    @ResponseBody

    public LayerTableVO list(Model model, HttpServletRequest request) {
//        model.addAttribute("request", request);
//        model.addAttribute("user", SubjectUtil.getSuperUser());
//        QueryWrapper<Article> wrapper = new QueryWrapper<>();
//        model.addAttribute("request", request);
//        model.addAttribute("request", request);

        LayerTableVO lt = new LayerTableVO();
        //获取作者
//        String author = request.getParameter("author");
//        //  获取类型id
//        String article_type_id = request.getParameter("article_type_id");
//
//        //获取发布状态
//        String state = request.getParameter("state");
//        System.out.println("article_type_id    :"+article_type_id);
        //获取分页
        Integer tagsId = Integer.parseInt(request.getParameter("page"));
        Integer pageNum = Integer.parseInt(request.getParameter("limit"));
        //如果都不为空
        lt=articleTypeService.TypeList(tagsId,pageNum);


        return lt;
    }




}
